"""班级页面"""
from selenium.webdriver.common.by import By
from common.base import Base


class ClassPage(Base):
    url = "/Interact/index/courseid/MDAwMDAwMDAwMLR2ud6G36ew.html"

    # 页面元素定位
    homework_locator = (By.XPATH, "//a[text()='作业']")  # 作业页签
    upload_homework_locator = (By.XPATH, "//a[text()='上传作业']")  # 上传作业
    submit_locator = (By.CLASS_NAME, "tj-btn")  # 提交按钮
    add_homework_locator = (By.XPATH, "//div[@class='shangchuan']/a")  # 添加作业
    leave_msg_locator = (By.XPATH, "//span[contains(text(),'点击添加留言')]")  # 作业留言
    leave_msg_text_locator = (By.ID, "comment")  # 作业留言文本框
    save_locator = (By.XPATH, "//textarea[@id='comment']/following-sibling::a")

    def homework(self):
        # 点击作业页签
        self.click(self.homework_locator)

    def upload_homework(self):
        # 上传作业
        self.click(self.upload_homework_locator)

    def add_homework_file(self):
        # 添加作业文件
        self.click(self.add_homework_locator)

    def leave_msg(self,data):
        #作业留言
        self.click(self.leave_msg_locator)
        self.input(self.leave_msg_text_locator,data)

    def save_msg(self):
        #点击保存
        self.click(self.save_locator)
